package udp;

import java.io.IOException;
import java.net.SocketException;
import java.util.HashMap;
import java.util.Map;

/**
 * Created with IntelliJ IDEA
 * Description
 * User：chenshu
 * Date：2023-11-23
 * Time：13:23
 */
public class DictServer extends EchoServer{
    private Map<String, String> dict = new HashMap<>();
    public DictServer(int port) throws SocketException {
        super(port);
        dict.put("hello", "你好");
        dict.put("world", "世界");
        dict.put("cat", "猫");
        dict.put("dog", "狗");
        dict.put("I", "我");
    }

    @Override
    public String process(String request) {
       return dict.getOrDefault(request, "词典里没有这个单词");
    }

    public static void main(String[] args) throws IOException {
        DictServer dictServer = new DictServer(30000);
        dictServer.start();
    }
}
